from concurrent.futures import ThreadPoolExecutor




class ThreadPool(object):
    __instance = None  # type: ThreadPoolExecutor

    __executor = None  # type: ThreadPoolExecutor

    def __init__(self):
        if ThreadPool.__instance is not None:
            raise Exception("ThreadPool is a Singleton, use get_instance method to get an instance!")
        ThreadPool.__executor = ThreadPoolExecutor(max_workers=200)
        ThreadPool.__instance = self

    @staticmethod
    def get_instance():

        if ThreadPool.__instance is None:
            ThreadPool()
        return ThreadPool.__executor

    def __del__(self):
        ThreadPool.__executor.shutdown()